﻿Imports Entities
Imports Controller
Public Class DevolverPrestamo
    Private myController As New NegocioSQL
    Private Sub btnDevolver_Click(sender As Object, e As EventArgs) Handles btnDevolver.Click
        If (TxtDni.Text <> "" Or TxtFechaD.Text <> "" Or TxtIsbn.Text <> "" Or txtTitulo.Text = "" Or TxtFechaP.Text <> "") Then
            myController.SQLIntroducirDevolucion(New Prestamo(TxtIsbn.Text, TxtDni.Text, TxtFechaP.Text, TxtFechaD.Text))
            cmbPrestamos.DataSource = Nothing
            cmbPrestamos.DataSource = myController.SQLgetPrestamo
        End If

    End Sub

    Private Sub DevolverPrestamo_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        cmbPrestamos.DataSource = myController.SQLgetPrestamo
    End Sub

    Private Sub cmbPrestamos_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cmbPrestamos.SelectedIndexChanged
        Dim miPrestamo As Prestamo = cmbPrestamos.SelectedItem
        TxtIsbn.Text = miPrestamo.Isbn
        TxtDni.Text = miPrestamo.Dni
        TxtFechaD.Text = miPrestamo.FechaDevolucion
        TxtFechaP.Text = miPrestamo.FechaPrestamo
        txtTitulo.Text = myController.SQLgetTituloPorPrstamo(miPrestamo)
    End Sub

End Class